package com.gxa.logistics.controller;

import com.gxa.logistics.common.base.PageWrapperDTO;
import com.gxa.logistics.common.base.RespResult;
import com.gxa.logistics.domain.dto.*;
import com.gxa.logistics.domain.vo.InsuranceVO;
import com.gxa.logistics.domain.vo.MessionVO;
import com.gxa.logistics.service.InsuranceService;
import com.gxa.logistics.service.MessionService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;

@Api(tags = "车辆管理—保险列表")
@RestController
@RequestMapping("/vehicle_insurance")
@Slf4j
public class InsuranceController {

    @Autowired
    private InsuranceService insuranceService;

    /**
     * 获取用户列表
     */
    @ApiOperation(value = "获取保险列表-分页", notes = "获取保险列表-分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNo", value = "当前页码数", defaultValue = "1", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", defaultValue = "10", paramType = "query", dataType = "String")
    })
    @GetMapping("/list")
    public RespResult<PageWrapperDTO<InsuranceVO>> list(InsuranceReqListDTO insuranceReqListDTO) {
        return insuranceService.list(insuranceReqListDTO);
    }

    /**
     * 新增车辆
     */
    @ApiOperation(value = "新增保存", notes = "新增保存")
    @PostMapping("/save")
    public RespResult save(@RequestBody @ApiParam(name = "data", value = "系统用户添加实体") @Validated InsuranceSaveDTO insuranceSaveDTO) {
        // 保存
        insuranceService.insertInsurance(insuranceSaveDTO);
        return RespResult.success();
    }

    /**
     * 修改车辆信息
     */
    @ApiOperation(value = "修改保存", notes = "修改保存")
    @PostMapping("/update")
    public RespResult update(@RequestBody @ApiParam(name = "data", value = "车辆修改实体") InsuranceUpdateDTO insuranceUpdateDTO) {
        insuranceService.updateInsurance(insuranceUpdateDTO);
        return RespResult.success();
    }


    /**
     * 删除用户
     */
    /**
     * 删除用户
     */
    @ApiOperation(value = "删除车辆保险", notes = "删除车辆保险")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lpnum", value = "车牌号码", required = true, dataType = "String", paramType = "path"),
    })
    @PostMapping("/delete/{lpnum}")
    public RespResult delete(@PathVariable String lpnum) {
        insuranceService.deleteInsuranceByLpnum(lpnum);
        return RespResult.success();
    }


}
